--
-- Author: ping.wang
-- Date: 2018-12-17 10:33:43
--
-- RewardDayLoginRender
-- 七日登陆送所用的render，左侧滑动列表用的按钮

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.RewardSignRender))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self._ui.selected_btn:setSwallowTouches(false)
    self:setContentSize( self._ui.selected_btn:getContentSize() )
    self._ui.selected_btn:addClickEventListener(function()
        if self._onClick then
            self:_onClick(self)
        end
    end)
    self:refresh()
end

--idx = i, sendIdx = v.idx, award = loot, iconName = v.iconName,des = v.des, haveGet = v.haveGet, canGet = v.canGet
--idx现在不用了用sendIdx
function ClassRef:refresh()
    if self._data then
        self:setVisible( true )

        local data = self._data.data

        self._ui.name_1:setString(L("sign7_"..data.sendIdx))
        self._ui.name_2:setString(L("sign7_"..data.sendIdx))
        local dayIdx = data.sendIdx --第幾天的索引
        self._ui.icon:loadTexture(Res.activityIconPath.."into_icon_"..dayIdx..".png")

    else
        self:setVisible( false )
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

function ClassRef:setSelected(bl)
    self._ui.name_2:setVisible(bl)
    self._ui.name_1:setVisible(not bl)

    self._ui.selected_btn:setBright(not bl)

end

--表明是第几个
function ClassRef:getIdx()
    return self._data.id
end

function ClassRef:getData()
    return self._data
end

return ClassRef
